HowtoBecomeaProgrammer
About UsContact UsSets are another type of arrays, which are once again lists, sets, tuples, and dictionaries. The difference between sets and other types of arrays is that the data in sets aren't in a set order and there are no indexes, like list[0] or tuple[1]. Here's an example of a list:
a_set = {1, 2, 3}
print(a_set[1])
a_set[2] = 5
We first we create a set, then we try to output a specific index, however with sets we can not do this, and we try to set a specific index equal to a new value, but once again we can not access or reassign a specific index. We can, however, use the add() function for a single piece of data, or the update() function to update multiple pieces of data using a list.
We can also remove a specific item, not a specific index, from a list, using the remove() function. The clear() function will empty the set, and just like lists, you can use the set() function to create a set.